void translatePositions() { 

	float3 Trat[NUMSITES];
	float3 Diff[NUMSITES];
	float3 radmat[NUMSITES];
	prec DR[NUMSITES][NUMDIMS];

	prec r = genrand_real(); 
	prec dx = moveSize*(0.5-r);

	r = genrand_real(); 
	prec dy = moveSize*(0.5-r); 
                
	r = genrand_real(); 
	prec dz = moveSize*(0.5-r);

	for(int i=0; i < NUMSITES; i++) {

		Trat[i].x = hAtom[moveSelect*3+i].x+dx;
		Trat[i].y = hAtom[moveSelect*3+i].y+dy;
		Trat[i].z = hAtom[moveSelect*3+i].z+dz;//carbon position

	}
                
	//calculate and store difference of new coords
	for(int i=0; i < NUMSITES; i++) {
	
		Diff[i].x= Trat[i].x-Trat[2].x;
		Diff[i].y= Trat[i].y-Trat[2].y;
		Diff[i].z= Trat[i].z-Trat[2].z;

	} 
 
	//pick random number to change drot
	r = genrand_real();
	prec drot = dRm*(0.50-r); 

	//pick random number for rotation matrix axis
	int axis = (int)((genrand_real())*3)+1;

	if(axis == 1) {
		radmat[0].x = 1; radmat[0].y = 0;		   radmat[0].z = 0;
		radmat[1].x = 0; radmat[1].y = cos(drot);  radmat[1].z = sin(drot);
		radmat[2].x = 0; radmat[2].y = -sin(drot); radmat[2].z = cos(drot);
    }
        
	if (axis == 2) {
		radmat[0].x = cos(drot); radmat[0].y = 0; radmat[0].z = -sin(drot); 
		radmat[1].x = 0;         radmat[1].y = 1; radmat[1].z = 0;
		radmat[2].x = sin(drot); radmat[2].y = 0; radmat[2].z = cos(drot); 
	} 

    if(axis == 3) {
		radmat[0].x = cos(drot);  radmat[0].y = sin(drot); radmat[0].z = 0;
		radmat[1].x = -sin(drot); radmat[1].y = cos(drot); radmat[1].z = 0;
		radmat[2].x = 0;          radmat[2].y = 0;         radmat[2].z = 1; 
	} 

	prec sum;
	//apply rotation matrix to Diff
	for(int i=0; i<=2; i++) {
		for(int j=0; j<=2; j++){
			sum = 0.0;
			sum = sum + Diff[i].x*radmat[j].x;
			sum = sum + Diff[i].y*radmat[j].y;
			sum = sum + Diff[i].z*radmat[j].z;
			DR[i][j]= sum;
		}
	}

	//add DR to CM to get new rat
	for(int i=0; i< NUMSITES; i++) {
		hAtom[moveSelect*3+i].x = DR[i][0] + Trat[2].x;
		hAtom[moveSelect*3+i].y = DR[i][1] + Trat[2].y;
		hAtom[moveSelect*3+i].z = DR[i][2] + Trat[2].z;

	}

	//Make sure the particle isn't out of the box after this move
	for (int i = 0; i < 3; i++) {
		hAtom[moveSelect*3+i].x -= box.x*floor(hAtom[moveSelect*3+i].x/box.x);
		hAtom[moveSelect*3+i].y -= box.y*floor(hAtom[moveSelect*3+i].y/box.y);
		hAtom[moveSelect*3+i].z -= box.z*floor(hAtom[moveSelect*3+i].z/box.z);
	}
} 


void savePositions(char *flag) {
        
	if (flag == "save") {    
		for(int i=0; i < NUMSITES; i++) {
			refConfig[moveSelect*3+i].x = hAtom[moveSelect*3+i].x;
			refConfig[moveSelect*3+i].y = hAtom[moveSelect*3+i].y;
			refConfig[moveSelect*3+i].z = hAtom[moveSelect*3+i].z;
		}
	} else if (flag == "restore") {
		for(int i=0;i< NUMSITES; i++) {           
			hAtom[moveSelect*3+i].x = refConfig[moveSelect*3+i].x;
			hAtom[moveSelect*3+i].y = refConfig[moveSelect*3+i].y;
			hAtom[moveSelect*3+i].z = refConfig[moveSelect*3+i].z;
		}
    } 
}

//Places everything into the box
void normalizePositions() {
	for(int i = 0; i < nMolecules; i++) {
		for(int j = 0; j < 3; j++) {
			hAtom[i*3+j].x -= box.x*floor(hAtom[i*3+j].x/box.x);
			hAtom[i*3+j].y -= box.y*floor(hAtom[i*3+j].y/box.y);
			hAtom[i*3+j].z -= box.z*floor(hAtom[i*3+j].z/box.z);
		}	
	}
}

